﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:XamlingCore.SL.Controls.Dialog" xmlns:Content="clr-namespace:XamlingCore.SL.Controls.Content" xmlns:ContentTemplate="clr-namespace:XamlingCore.SL.Controls.ContentTemplate" x:Class="XamlingCore.SL.Controls.Dialog.DefaultXDialog"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>



        <Style x:Key="StandardDialogButton" TargetType="Button">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF2D2D2D" Offset="0"/>
                        <GradientStop Color="Black" Offset="1"/>
                        <GradientStop Color="#FF252525" Offset="0.534"/>
                        <GradientStop Color="#FF313131" Offset="0.513"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="Padding" Value="3"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="#FF4D4D4D"/>
            <Setter Property="Width" Value="80"/>
            <Setter Property="Height" Value="40"/>
            
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" CornerRadius="5"/>
                            <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/>
                            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#34FFFFFF" StrokeThickness="1"/>
                            <Border x:Name="border" BorderThickness="1" Background="#19FFFFFF" Opacity="0"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="XDialogDefaultStyle" TargetType="local:XHeaderedContentControl">
            <Setter Property="Foreground" Value="#FF000000"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="local:XHeaderedContentControl">
                        <Grid Background="#66000000"  x:Name="grid" RenderTransformOrigin="0.5,0.5">
                            <Grid.RenderTransform>
                                <CompositeTransform/>
                            </Grid.RenderTransform>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="ContentStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.3">
                                    		<VisualTransition.GeneratedEasingFunction>
                                    			<BackEase EasingMode="EaseOut"/>
                                    		</VisualTransition.GeneratedEasingFunction>
                                    	</VisualTransition>
                                        <VisualTransition GeneratedDuration="0:0:0.3" To="NoContent">
                                        	<VisualTransition.GeneratedEasingFunction>
                                        		<CircleEase EasingMode="EaseIn"/>
                                        	</VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="NormalReverse"/>
                                    <VisualState x:Name="BeforeTransition">
                                    	<Storyboard>
                                    		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
                                    		<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="grid">
                                    			<DiscreteObjectKeyFrame KeyTime="0">
                                    				<DiscreteObjectKeyFrame.Value>
                                    					<Visibility>Collapsed</Visibility>
                                    				</DiscreteObjectKeyFrame.Value>
                                    			</DiscreteObjectKeyFrame>
                                    		</ObjectAnimationUsingKeyFrames>
                                    		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="grid1" d:IsOptimized="True"/>
                                    		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="grid1" d:IsOptimized="True"/>
                                    	</Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="BeforeTransitionReverse"/>
                                    <VisualState x:Name="NoContent">
                                    	<Storyboard>
                                    		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
                                    		<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="grid">
                                    			<DiscreteObjectKeyFrame KeyTime="0">
                                    				<DiscreteObjectKeyFrame.Value>
                                    					<Visibility>Collapsed</Visibility>
                                    				</DiscreteObjectKeyFrame.Value>
                                    			</DiscreteObjectKeyFrame>
                                    		</ObjectAnimationUsingKeyFrames>
                                    		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="grid1" d:IsOptimized="True"/>
                                    		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="grid1" d:IsOptimized="True"/>
                                    	</Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="grid1" Height="230" Margin="20, 0, 20, 0" RenderTransformOrigin="0.5,0.5">
                            	<Grid.RenderTransform>
                            		<CompositeTransform/>
                            	</Grid.RenderTransform>

                                <Grid.RowDefinitions>
                                    <RowDefinition Height=".25*"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height=".3*"/>

                                </Grid.RowDefinitions>
                                <Border BorderBrush="#FF6C6C6C" BorderThickness="2" CornerRadius="5" Grid.RowSpan="3">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#D8252525" Offset="0"/>
                                            <GradientStop Color="#D9000000" Offset="1"/>
                                            <GradientStop Color="#D91B1B1B" Offset="0.496"/>
                                            <GradientStop Color="#D8060606" Offset="0.5"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                                <Grid Grid.Row="1">
                                    <ContentPresenter Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Grid>
                                <Grid>
                                    <ContentPresenter Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding HeaderContentTemplate}" Content="{TemplateBinding HeaderContent}" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Grid>
                                <Grid VerticalAlignment="Bottom" Grid.RowSpan="3" >
                                    <ContentPresenter Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding FooterContentTemplate}" Content="{TemplateBinding FooterContent}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Grid>
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="XDialogDefaultFooterContent">
            <Grid Margin="0,0,0,15" >
                <Content:XContentControl Content="{Binding}" ContentTemplateSelectorBinding="{Binding DialogMessage.MessageButtons}">
                    <ContentTemplate:ObjectContentTemplateSelector Value="Okay">
                        <DataTemplate>
                            <Grid>
                                <StackPanel Orientation="Horizontal">
                                    <Button Command="{Binding OkayCommand}" Content="OK" Style="{StaticResource StandardDialogButton}"/>
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ContentTemplate:ObjectContentTemplateSelector>
                    <ContentTemplate:ObjectContentTemplateSelector Value="OkayCancel">
                        <DataTemplate>
                            <Grid>
                                <StackPanel Orientation="Horizontal">
                                    <Button Content="OK" Style="{StaticResource StandardDialogButton}"/>
                                    <Button Content="Cancel" Style="{StaticResource StandardDialogButton}"/>
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ContentTemplate:ObjectContentTemplateSelector>
                </Content:XContentControl>

            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="XDialogDefaultHeaderTemplate">
            <Grid>
                <TextBlock TextWrapping="Wrap" Text="{Binding DialogMessage.Title}" d:LayoutOverrides="Width, Height" FontFamily="Trebuchet MS" FontSize="18.667" TextTrimming="WordEllipsis"/>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="XDialogDefaultMessageTemplate">
            <Grid Margin="15, 0, 0, 15">
                <TextBlock TextWrapping="Wrap" Text="{Binding DialogMessage.Body}" d:LayoutOverrides="Width, Height" FontFamily="Trebuchet MS" FontSize="16"/>
            </Grid>
        </DataTemplate>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">

        <local:XHeaderedContentControl  FooterContent="{Binding CurrentDialogObject}" HeaderContent="{Binding CurrentDialogObject}" Content="{Binding CurrentDialogObject}" Style="{StaticResource XDialogDefaultStyle}" FooterContentTemplate="{StaticResource XDialogDefaultFooterContent}" Foreground="#FFD0D0D0" HeaderContentTemplate="{StaticResource XDialogDefaultHeaderTemplate}" ContentTemplate="{StaticResource XDialogDefaultMessageTemplate}"/>

    </Grid>
</UserControl>
